import java.math.BigInteger;
import java.util.Scanner;

public class Text {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String StrA = scanner.nextLine();
        String StrB = scanner.nextLine();
        BigInteger a = new BigInteger(StrA);
        BigInteger b = new BigInteger(StrB);
        BigInteger gcd = a.gcd(b);
        System.out.println(gcd);
    }
}